package com.fr.cell;

import java.awt.Rectangle;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class GridSelection
  implements Cloneable, Serializable
{
  public static final int CELL = 0;
  public static final int FLOAT = 1;
  public static final int CHART = 2;
  private int type = 0;
  private Rectangle editRectangle = new Rectangle(0, 0, 1, 1);
  private List cellRectangleList = new ArrayList();
  private List floatNameList = new ArrayList();

  public GridSelection()
  {
    this.cellRectangleList.add(new Rectangle(0, 0, 1, 1));
  }

  public int getType()
  {
    return this.type;
  }

  public void setType(int paramInt)
  {
    this.type = paramInt;
    if (this.type == 1)
    {
      setEditBounds(0, 0, 1, 1);
      clearCellRectangles();
    }
    else
    {
      clearAllFloatName();
    }
  }

  public Rectangle getEditRectangle()
  {
    return this.editRectangle;
  }

  public void setEditBounds(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    this.editRectangle.setBounds(paramInt1, paramInt2, paramInt3, paramInt4);
  }

  public void setOnlyCellBounds(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    Rectangle localRectangle = null;
    if (this.cellRectangleList.size() > 0)
      localRectangle = (Rectangle)this.cellRectangleList.get(0);
    else
      localRectangle = new Rectangle();
    this.cellRectangleList.clear();
    localRectangle.setBounds(paramInt1, paramInt2, paramInt3, paramInt4);
    this.cellRectangleList.add(localRectangle);
  }

  public Rectangle getFirstCellRectangle()
  {
    return ((Rectangle)this.cellRectangleList.get(0));
  }

  public Rectangle getLastCellRectangle()
  {
    return ((Rectangle)this.cellRectangleList.get(this.cellRectangleList.size() - 1));
  }

  public void addCellRectangle(Rectangle paramRectangle)
  {
    int i = this.cellRectangleList.indexOf(paramRectangle);
    if (i != -1)
      this.cellRectangleList.remove(i);
    this.cellRectangleList.add(paramRectangle);
  }

  public int getCellRectangleCount()
  {
    return this.cellRectangleList.size();
  }

  public Rectangle getCellRectangle(int paramInt)
  {
    return ((Rectangle)this.cellRectangleList.get(paramInt));
  }

  public void clearCellRectangles()
  {
    for (int i = this.cellRectangleList.size() - 1; i > 0; --i)
      this.cellRectangleList.remove(i);
  }

  public void clearAllCellRectangles()
  {
    for (int i = this.cellRectangleList.size() - 1; i >= 0; --i)
      this.cellRectangleList.remove(i);
  }

  public boolean containsCell(int paramInt1, int paramInt2)
  {
    for (int i = 0; i < this.cellRectangleList.size(); ++i)
    {
      Rectangle localRectangle = (Rectangle)this.cellRectangleList.get(i);
      if (localRectangle.contains(paramInt1, paramInt2))
        return true;
    }
    return false;
  }

  public void addFloatName(String paramString)
  {
    this.floatNameList.add(paramString);
  }

  public int getFloatNameCount()
  {
    return this.floatNameList.size();
  }

  public String getFloatName(int paramInt)
  {
    return ((String)this.floatNameList.get(paramInt));
  }

  public String getLastFloatName()
  {
    return getFloatName(getFloatNameCount() - 1);
  }

  public void removeFloatName(String paramString)
  {
    this.floatNameList.remove(paramString);
  }

  public void clearAllFloatName()
  {
    this.floatNameList.clear();
  }

  public boolean containFloatName(String paramString)
  {
    return this.floatNameList.contains(paramString);
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    GridSelection localGridSelection = (GridSelection)super.clone();
    if (this.editRectangle != null)
      localGridSelection.editRectangle = ((Rectangle)this.editRectangle.clone());
    ArrayList localArrayList1 = new ArrayList(this.floatNameList.size());
    localGridSelection.floatNameList = localArrayList1;
    int i = 0;
    int j = this.floatNameList.size();
    while (i < j)
    {
      localArrayList1.add(this.floatNameList.get(i));
      ++i;
    }
    ArrayList localArrayList2 = new ArrayList(this.cellRectangleList.size());
    localGridSelection.cellRectangleList = localArrayList2;
    j = 0;
    int k = this.cellRectangleList.size();
    while (j < k)
    {
      localArrayList2.add((Rectangle)((Rectangle)this.cellRectangleList.get(j)).clone());
      ++j;
    }
    return localGridSelection;
  }
}